﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using SiGeSIB.GUI.Common.DedaGrid.Filter;
using SiGeSIB.Data.Common;
using System.Windows.Forms;

namespace SiGeSIB.GUI.Common
{
	public static class Extensions
	{
		public static void Filter(this DataTable table, DedaGridFilterCollection conditions)
		{
			if (table != null)
			{
				table.DefaultView.RowFilter = null;

				if (conditions != null)
				{
					string filter = conditions.ToString();

					if (!string.IsNullOrEmpty(filter))
					{
						table.DefaultView.RowFilter = filter;
					}
				}
			}
		}

		public static string GetValue(this MaskedTextBox txtBox)
		{
			return txtBox != null && txtBox.MaskedTextProvider != null ? txtBox.MaskedTextProvider.ToString(false, false) : null;
		}
	}
}
